package com.action;

import java.sql.ResultSet;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.util.DB;

public class sellerpayment extends ActionSupport

{
	private String radiobutton1;
	private String radiobutton;
	private Integer creditcardno;
	private String month;
	private Integer year;
	private String cardholder;
	private Integer cvv;
	private String message;
	ResultSet res=null;
	String bankname1;
	Float balance1;
	

	public String execute()throws Exception
	{
		Map session;
		session=ActionContext.getContext().getSession();
		Integer prodid=(Integer)session.get("prodid");
		System.out.println("The prodid in sellerpayment is"+prodid);
		String query="select * from bank;";
		res=DB.readFromBmtcDB(query);
		System.out.println("res is"+res);
		while(res.next())
		{
			Integer creditcardno1=res.getInt("creditcardno");
			String month1=res.getString("month");
			Integer year1=res.getInt("year");
			String cardholder1=res.getString("cardholder");
			Integer cvv1=res.getInt("cvv");
			balance1=res.getFloat("balance");
			bankname1=res.getString("bankname");
			
			
			if((creditcardno1.equals(creditcardno))&&(month1.equalsIgnoreCase(month))&&(year1.equals(year))&&(cardholder1.equalsIgnoreCase(cardholder))&&(cvv1.equals(cvv))&&(radiobutton.equalsIgnoreCase(bankname1)))
			{
				System.out.println("The prodid in sellerpayment is"+prodid);
				String insert_query="update listingdetail set status=1 where prodid="+prodid+";";
				DB.update(insert_query);
				
				balance1=balance1-2;
				String update_bank="update bank set balance="+balance1+" where creditcardno="+creditcardno1+";";
				DB.update(update_bank);
				return "success";
			}
			
		}
		
		message="Incorrect Details";
		return "error";
	}




	public String getRadiobutton1() {
		return radiobutton1;
	}




	public void setRadiobutton1(String radiobutton1) {
		this.radiobutton1 = radiobutton1;
	}




	public String getRadiobutton() {
		return radiobutton;
	}




	public void setRadiobutton(String radiobutton) {
		this.radiobutton = radiobutton;
	}




	



	public String getMonth() {
		return month;
	}




	public void setMonth(String month) {
		this.month = month;
	}


	public String getCardholder() {
		return cardholder;
	}




	public void setCardholder(String cardholder) {
		this.cardholder = cardholder;
	}




	public Integer getCreditcardno() {
		return creditcardno;
	}




	public void setCreditcardno(Integer creditcardno) {
		this.creditcardno = creditcardno;
	}




	public Integer getYear() {
		return year;
	}




	public void setYear(Integer year) {
		this.year = year;
	}




	public Integer getCvv() {
		return cvv;
	}




	public void setCvv(Integer cvv) {
		this.cvv = cvv;
	}




	public String getMessage() {
		return message;
	}




	public void setMessage(String message) {
		this.message = message;
	}




	
}
